1. 创建一个字符串’-here come buses-’
时间: 2023-10-26 08:07:15 浏览: 36
好的,以下是创建字符串'-here come buses-'的代码:
```python
str = '-here come buses-'
print(str)
```
输出结果为:
```
-here come buses-
```
这样就创建了一个名为`str`的字符串,并将其输出。
相关问题
1. 创建一个字符串’-here come buses-’,并按顺序完成: (1)将其命名为str,统计该字符串中‘e’出现的次数;
好的,以下是完成你的要求的代码:
```python
str = '-here come buses-'
count = str.count('e')
print("字符串中'e'出现的次数为:", count)
```
输出结果为:
```
字符串中'e'出现的次数为: 2
```
注意,在Python中,字符串的计数是从0开始的,因此上面的输出结果中,第一个'e'的位置为1,第二个'e'的位置为12。
创建一个字符串’---here come buses---’,将该字符串小写字母全部转换成大写字母;
Sure, here's the code to create the string '---here come buses---' and convert it to uppercase letters:
```lua
local str = '---here come buses---'
str = string.upper(str)
print(str)
```
Output:
```
---HERE COME BUSES---
```