Skip to content
HDsky's Blog
Go back

Python读书笔记

自己写读书笔记,记录下自己的python学习中遇到的一些问题或者一些奇怪的东西。

#! /usr/bin/env python3

age = input("input your age:")
if age >= 18:
    print("adult")
else:
    print("young")

执行后会报错

TypeError: '>=' not supported between instances of 'str' and 'int'

原因是input()输入的是str类型,需要将其转成int型。

int(input("input your age:"))

Share this post:

Previous Post
Tensorflow 折腾之旅
Next Post
有些必须要告诉大家的事