求用Python写个小函数:让用户在界面输入一个数字,然后返回输出这个数字加1的结果

求用Python写个小函数:让用户在界面输入一个数字,然后返回输出这个数字加1的结果

问题描述:

求用Python写个函数:让用户在界面输入一个数字,然后返回输出这个数字加1的结果,小白刚学Python,求指点,谢谢!

不好意思:
return x+1 不需要,只能在函数内使用
可以像下面这么写:

x = int(input("x = "))
print("Output is:",x+1)

建议阅读《Python基础教程》来学习Python哦~

 x = int(input("x = "))
 return x+1

import sys
def func_readnumber():
print('input a number:')
a=int(sys.stdin.readline())
print(a+1)
func_readnumber()

    def num():
        number =  int(input('请输入一个数字: '))
        print('你输入了: ' + str(number + 1))
    num()