简体   繁体   English

从 function 输入和之后的文本中获取变量

[英]Get variables from function input and text after

So id like to make varibles from my function input所以我喜欢从我的 function 输入中创建变量

So basically, the if statement should check if the varible is True or not.所以基本上,if 语句应该检查变量是否为真。 And i want to use the function input + ”-outcome” to check.我想使用 function 输入 + “-outcome” 来检查。

Function-outcome = True
Function2-outcome = False
c
def a(B):
 Global c
 If f’{B}-outcome’ == True:
  Print(”yes”)
 Else:
  Print(”no”)
a(”function”)
a(”function2”)

Here is an example, to make you understand my problem better!这是一个例子,让你更好地理解我的问题!

I've tried to find a solution but don't find it anywhere我试图找到解决方案,但在任何地方都找不到

Thanks!谢谢!

import yfinance as yf
from datetime import date
import pandas as pd

d_start = '2022-01-01'
d_end = date.today().strftime('%Y-%m-%d')

#top50 S&P to create a list, if you will use a variable from an API you will just need to declare it as a string
#you can create a list of your fav ones and it will work the same, I grabbed from this site because it was the top 50 easy to get
tl = pd.read_html('https://dailypik.com/top-50-companies-sp-500/')[0]['Symbol'].to_list()

def main(l, d_start, d_end):

#I used the download function here, you will use the one that will fulfill your aim, analysis, actions, balance_sheet
#for isntance df = yf.earnings
df = yf.download(str(l), start=d_start, end=d_end)
#you can't assign a variable with a fstring, the work around is name the df opening opportunities later on
df.name = l

return df

df_list = [main(k, d_start, d_end) for k in tl]
di_ticks = {k:v for k,v in zip([df_list[i].name for i in range(0, len(df_list))], df_list)}
#here you can pass any tick that you have in the tl(tick list)
di_ticks['MSFT']

微软公司

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 RNN:在训练模型后从文本输入中获取预测 - RNN: Get prediction from a text input after the model is trained 如何从另一个模块中的函数中的变量获取输入值并使用它们? - How to get input values from variables that are in a function within another module and use them? 从不同的输入字段获取不同的变量 - Get different variables from different input fields 如何从函数到另一个函数获取变量? - How to get variables from a function to another function? 如何在kivy上获得类似函数的文本输入? - How to get text input like function on kivy? 再次执行我们的python代码后,将我们从用户那里获得的输入保留在文本文件中,以便在我们需要时从文本文件中获取该输入以显示在屏幕上 - Keep input we get from user in text file after we execute our python code again to get that input to show in the screen when we need it from text file 如何在 function 内部时从 tkinter 文本小部件获取输入 - how to get input from a tkinter text widget when its inside a function 从txt文件读取输入变量的文本文件 - Text file reading input variables from txt file 如何从 Tkinter Text Widget 获取输入? - How to get the input from the Tkinter Text Widget? 如何从输入区域获取文本 - How to get text from input area
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM