contents of file to variable python

Solutions on MaxInterview for contents of file to variable python by the best coders in the world

showing results for - "contents of file to variable python"
Elizabeth
05 Mar 2019
1# First, install PyVariable with - pip install pyvariable
2
3import pyvariable
4
5variable = pyvariable.LocalVariable()
6variable.save("var_name", "value")  # Can be used any data type as variable value
7var_name = variable.read_str("var_name")  # This will read the value of var_name
8
9"""
10Methods -
11variable.read_int(var_name) for reading integer variable, 
12variable.read_float(var_name) for reading float variable,
13variable.read_str(var_name) for reading string variable,
14variable.read_list(var_name) for reading list,
15variable.read_tuple(var_name) for reading tuple,
16variable.read_set(var_name) for reading set,
17variable.read_dict(var_name) for reading dictionary,
18variable.read_bool(var_name) for reading boolean variable,
19variable.exists(var_name) to search if a variable exists,
20variable.get_all_as_dict() to get all variables with value in dictionary format.
21"""
Tyrone
20 Jun 2018
1with open ("data.txt", "r") as myfile:
2    data=myfile.readlines()