私信  •  关注

obami

obami 最近创建的主题
obami 最近回复了
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)