社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  obami  »  全部回复
回复总数  1
3 年前
回复了 obami 创建的主题 » 在Python中将\n用作普通字符串

成功的解决方案:

def ask_num():
    num_list = []
    # ask for a number (we will make it a string so we can add comma and /n)
    num = input("Enter numbers: ")
    # put the num in the list
    num_list.append(num)
    # seperate the numbers
    num_list = num.split(r"\n")
    # print the list
    print(num_list)