Here's my code:
import sys
def main():
a = bool(sys.argv[1])
b = str(sys.argv[2])
c = float(sys.argv[3])
d = int(sys.argv[4])
for x in sys.argv:
print(x)
if a == True and b > d:
print(c+d)
else:
b_upper = b.upper()
print(b_upper)
main()
Im getting this error:
File "commline.py", line 19, in <module>
main()
File "commline.py", line 10, in main
if a == True and b > d:
TypeError: unorderable types: str() > int()
Im trying to get the program to do this:
Here is an example of what the output should look like:
python3 commline.py True "Peter Pan" 3.14159 7
True
Peter Pan
3.14159
7
Result:
10.14159
使用len()
:
if a == True and len(b) > d:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.