python - bt.append(int(input(f"Enter burst time for process {i} ->"))) 它是我代码的第 11 行,当我运行代码时它显示无效语法
问题描述
当我运行 FCFS 调度程序时,它指出了一个错误
bt.append(int(input(f"Enter burst time for process: {i} ->")))
说语法错误
#python code to implement FCFS CPU Scheduling
n = int(input("Enter number of processes:"))
bt = [] # Burst Time
wt = [0,0,0,0,0,0,0,0,0] # Waiting Time
tat = [0,0,0,0,0,0,0,0,0,0] # Turn around time
#Take input
for i in range (0,n):
bt.append(int(input(f"Enter burst time for process: {i} ->")))
#Waitng time
for i in range(1,n):
wt[i] = 0
for j in range (0,i):
wt[i] += bt[i]
# Turn around time
for i in range(0,n):
tat[i] = wt[i] + bt[i]
print()
print("\t Process \t\t Burst Time \t\t Waitng Time \t\t Turn around time")
for i in range(0,n):
print(f"\t P[{i}] \t\t {bt[i]} \t\t {tat[i]} ")
解决方案
您需要使用格式方法:
"Enter burst time for process: {i} ->".format(i=i)
推荐阅读
- file - 根据文本文件中的字符串检查文件是否存在于具有动态名称的同一目录中?
- python - 将 python 列表值添加到输入 Flask
- c++ - C++赋值运算符,我们可以用copy来代替吗?
- java - 将布尔值传递给 Oracle DBMS 中的 JPA 本机查询
- javascript - 为什么我的按钮需要点击两次才能触发
- amazon-web-services - 如何查看 Amazon S3 存储桶上的最新日志?
- javascript - 从烧瓶服务器发送到客户端 JavaScript 不发送到发送者
- module - 如何在moodle网站中运行SCORM模块?
- java - JUnit 在没有@BeforeEach 的情况下创建一个新的类实例?
- node.js - 如何在节点 js 中使用计时器发出 api 请求?