云计算笔记之python-day-01-python起步

这篇云计算笔记主要介绍了Python的起步,包括Python概述、环境准备,详细讲解了如何安装Python3.6,以及如何使用git进行版本控制。文章提到了git的三个区域:工作区、暂存区和版本库,并阐述了提交代码的流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

python

python概述

环境准备

安装python3.6

yum install epel-release
yum install python36

使用python3.6

[root@nsd-python yum.repos.d]# python36
Python 3.6.6 (default, Jan 26 2019, 16:53:05) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>> exit()

使用git

[root@nsd-python yum.repos.d]# yum -y install git
[root@nsd-python yum.repos.d]# git config --global user.name fleming
[root@nsd-python yum.repos.d]# git config --global user.email fleming@mial.joyours.com
[root@nsd-python yum.repos.d]# git config --global core.editor vim //如果需要编写日志,默认使用的编辑器是vim

[root@nsd-python yum.repos.d]# git config --list //查看
user.name=fleming
user.email=fleming@mial.joyours.com
core.editor=vim

如果写错了,可以直接修改下面的文件
[root@nsd-python yum.repos.d]# cat ~/.gitconfig 
[user]
	name = fleming
	email = fleming@mial.joyours.com
[core]
	editor = vim

git的三个区域

工作区:指的是编写代码的目录

暂存区:工作区和版本库之间的缓冲地带,工作区的文件先提交到暂存区,如果确定加入git管理,可以提交到版本库,如果后悔了,可以将文件从暂存区删除。

版本库:在工作区有一个.git目录,他是程序员保存代码,交给git管理的区域。

[root@nsd-python ~]# git init devops //新建仓库
Initialized empty Git repository in /root/devops/.git/
[root@nsd-python devops]# ls -la
total 4
drwxr-xr-x.  3 root root   18 Apr  2 23:41 .
dr-xr-x---. 17 root root 4096 Apr  2 23:41 ..
drwxr-xr-x.  7 root root  119 Apr  2 23:41 .git

[root@nsd-python devops]# git status //查看git状态
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)


[root@nsd-python devops]# vim python.py
[root@nsd-python devops]# mv python.py  hello.py
[root@nsd-python devops]# git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	hello.py
nothing added to commit but untracked files present (use "git add" to track)

[root@nsd-python devops]# git add .
[root@nsd-python devops]# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#	new file:   hello.py
#
[root@nsd-python devops]# git status -s #查看概要信息
A  hello.py

[root@nsd-python devops]# git commit -m "这是一个测试文件" #提交git到版本库
[master (root-commit) dddd097] 这是一个测试文件
 1 file changed, 1 insertion(+)
 create mode 100644 hello.py
[root@nsd-python devops]# git status -s #查看概要信息
[root@nsd-python devops]# git status
# On branch master
nothing to commit, working directory clean

[root@nsd-python devops]# git log #查看提交日志
commit dddd097be5d5675593b782f79cfd6a30ca7c3eef
Author: fleming <fleming@mial.joyours.com>
Date:   Tue Apr 2 23:49:03 2019 -0400

    这是一个测试文件

提交代码流程

[root@nsd-python devops]# echo 'print("123")' > new.py
[root@nsd-python devops]# git add .
[root@nsd-python devops]# git commit -m "add new file"
[master 8ddb25e] add new file
 1 file changed, 1 insertion(+)
 create mode 100644 new.py
[root@nsd-python devops]# git log
commit 8ddb25e0128cca4cf64b79fdb570be723640a6fd
Author: fleming <fleming@mial.joyours.com>
Date:   Wed Apr 3 00:04:46 2019 -0400

    add new file

commit dddd097be5d5675593b782f79cfd6a30ca7c3eef
Author: fleming <fleming@mial.joyours.com>
Date:   Tue Apr 2 23:49:03 2019 -0400

    这是一个测试文件


[root@nsd-python devops]# git ls-files  #查看版本库中文件
hello.py
new.py
[root@nsd-python devops]# git rm new.py #从git库中删除new.py文件
rm 'new.py'
[root@nsd-python devops]# git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	deleted:    new.py
#
[root@nsd-python devops]# git commmit -m "删除new.py"
git: 'commmit' is not a git command. See 'git --help'.

Did you mean this?
	commit
[root@nsd-python devops]# git ls-files
hello.py

python起步

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值