python print
时间: 2023-09-27 22:09:03 浏览: 56
The "print" function in Python is used to display output on the console or in a file. It can take one or more arguments and print them to the screen. Here's an example:
```
print("Hello, world!")
```
This will output "Hello, world!" on the console. You can also use the print function to print variables and expressions:
```
x = 10
y = 20
print(x + y)
```
This will output the sum of x and y, which is 30. The print function can also be used with formatting to display output in a specific way. For example:
```
name = "John"
age = 30
print("My name is {} and I am {} years old.".format(name, age))
```
This will output "My name is John and I am 30 years old."
阅读全文