输出prin时如何在python中生成新变量

2024-05-16 10:38:43 发布

您现在位置:Python中文网/ 问答频道 /正文

output=

Sign in to Twitter
Visit someone's profile
Saved search
Promote this Tweet
Block
Tweet with location
Spread the Location
Your list
Create a new list

Copy Tweet link
Embed this Tweet

我想做一个变量=“登录Twitter,访问某人的个人资料,保存搜索,推广此推文,阻止,推文位置,传播位置,你的列表,创建新列表,复制推文链接,嵌入此推文


Tags: toin列表outputsearchtwittervisitthis
1条回答
网友
1楼 · 发布于 2024-05-16 10:38:43

是你想要的吗

# -*- coding: UTF-8 -*-
import os
import sys
if __name__ == '__main__':

    var = '''
    Sign in to Twitter
    Visit someone's profile
    Saved search
    Promote this Tweet
    Block
    Tweet with location
    Spread the Location
    Your list
    Create a new list

    Copy Tweet link
    Embed this Tweet
    '''
   output = var.split('\n')
    print (var)
    print(output)

输出打印:

['', 'Sign in to Twitter', "Visit someone's profile", 'Saved search', 'Promote this Tweet', 'Block', 'Tweet with location', 'Spread the Location', 'Your list', 'Create a new list', '', 'Copy Tweet link', 'Embed this Tweet', ' ']

相关问题 更多 >