Shell变量

变量的定义

name="mini_xiang"

变量名命名注意事项:

* 变量名和“=”之间不能有空格。

* 命名只能使用英文字母,数字和下划线,首字符不能使用数字。

* 中间不能使用空格。

* 不能使用标点符号

* 不能使用bash的关键字(可用help命令查看保留关键字)。

使用变量

name="mini_xiang"
echo $name
echo ${name}

使用变量时,在变量名前加$符号即可。
{}是可选的主要是为了防止解释器识别不全的情况。

只读变量

使用readonly命令可以将命令定义为只读变量,只读变量的值不可以被修改

[root@localhost ~]# name="mini_xiang"
[root@localhost ~]# readonly name
[root@localhost ~]# name="qwe"
bash: name: readonly variable

修改只读变量系统会报错

[root@localhost ~]# readonly name1="mini"
[root@localhost ~]# name1="qweqwe"
bash: name1: readonly variable

删除变量

使用unset命令删除变量

[root@localhost ~]# name2="asdasd"
[root@localhost ~]# echo $name2
asdasd
[root@localhost ~]# unset name2
[root@localhost ~]# echo $name2

unset不能删除只读变量

变量类型

运行shell时,会同时存在三种变量:
1. 局部变量
局部变量在脚本或命令中定义,仅在当前shell实例中有效,其他shell启动的程序不能访问局部变量。
2. 环境变量
所有的程序,包括shell启动的程序,都能访问环境变量,有些程序需要环境变量来保证其正常运行。必要的时候shell脚本也可以定义环境变量。
3. shell变量
shell变量是由shell程序设置的特殊变量。shell变量中有一部分是环境变量,有一部分是局部变量,这些变量保证了shell的正常运行

AI实战-出租车价格数据集分析预测实例(含20个源代码+65.69 KB完整的数据集) 代码手工整理,无语法错误,可运行。 包括:20个代码,共124.23 KB;数据大小:1个文件共65.69 KB。 使用到的模块: pandas seaborn xgboost matplotlib.pyplot sklearn.preprocessing.RobustScaler sklearn.metrics.mean_absolute_error sklearn.model_selection.GridSearchCV sklearn.model_selection.train_test_split numpy warnings joblib sklearn.set_config sklearn.impute.SimpleImputer sklearn.preprocessing.LabelEncoder sklearn.model_selection.cross_val_score sklearn.preprocessing.StandardScaler sklearn.metrics.r2_score sklearn.metrics.mean_squared_error sklearn.linear_model.LinearRegression sklearn.linear_model.Lasso sklearn.linear_model.Ridge sklearn.neighbors.KNeighborsRegressor sklearn.ensemble.RandomForestRegressor sklearn.ensemble.GradientBoostingRegressor os sklearn.preprocessing.OneHotEncoder sklearn.compose.ColumnTransformer sklearn.pipeline.Pipeline sklearn.tree.DecisionTreeRegressor sklearn.svm.SVR sklearn.neural_network.MLPRegressor bokeh.io.output_notebook bokeh.io.show bokeh.plotting.figure bokeh.layouts.gridplot sklearn.preprocessing.PolynomialFeatures scipy.stats sklearn.metrics.mean_absolute_percentage_error sklearn.ensemble.ExtraTreesRegressor xgboost.XGBRegressor lightgbm.LGBMRegressor sklearn.impute.IterativeImputer statsmodels.stats.outliers_influence.variance_inflation_factor statsmodels.api sklearn.metrics.( plotly.express psynlig.plot_correlation_heatmap bokeh.plotting.show bokeh.plotting.output_notebook catboost.CatBoostRegressor sklearn.linear_model.ElasticNet missingno
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值