using EntMSM.SmsDbContext;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.Mvc; namespace EntMSM.Controllers
{
public class ContactsController : BaseController
{
EntSmsDbContext esd = new EntSmsDbContext(); /// <summary>
/// iqueryable转datatable
/// </summary>
/// <param name="enumerable"></param>
/// <returns></returns>
public static DataTable ConvertToDataTable(IQueryable<EntMSM.Models.ContactList> database)
{
DataTable table = new DataTable();
table.Columns.Add("编号", typeof(long));
table.Columns.Add("姓名", typeof(string));
table.Columns.Add("电话", typeof(string));
table.Columns.Add("邮箱", typeof(string));
table.Columns.Add("公司", typeof(string));
foreach (EntMSM.Models.ContactList info in database)
{
DataRow row = table.NewRow();
row["编号"] = info.Id;
row["姓名"] = info.LinkName;
row["电话"] = info.LinkMobile;
row["邮箱"] = info.LinkEmails;
row["公司"] = info.LinkCompany;
table.Rows.Add(row);
}
return table;
}
/// <summary>
/// ASP.NET MVC导出CSV文件
/// </summary>
/// <returns></returns>
public ActionResult DataSetToCsv()
{ //定义模版(标题、内容字段、格式化参数)
string[] template = new string[] { "编号,", "姓名,", "电话,", "邮箱,", "公司,","分组名" };
string contactsfileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
System.IO.MemoryStream output = new System.IO.MemoryStream();
System.IO.StreamWriter writer = new System.IO.StreamWriter(output, System.Text.Encoding.Default);
//输出标题
int lenght = template.GetLength();
for (int i = ; i < lenght; i++)
writer.Write(template[i]);
writer.WriteLine();
//输出内容
EntMSM.Models.Users curr = Session["LoginUser"] as EntMSM.Models.Users; //通过lambda表达式实现多表连接查询 显示对应的 短信账户名称 和角色权限对应名称
var contactsList = esd.ContactLists.AsEnumerable().Join(esd.Groupss, a => a.Groups_Id, b => b.Id,
(a, b) => new { a.Id, a.LinkCompany, a.LinkEmails, a.LinkMobile, a.LinkName, a.Uses_Id, b.Name }).Where(a => a.Uses_Id == curr.Id).DefaultIfEmpty();
//var contactsList = esd.ContactLists.Where(u => u.Uses_Id == curr.Id);
//List<EntMSM.Models.ContactList> lstUser = contactsList.Where(a=>a.Uses_Id==curr.Id).ToList();
if (contactsList != null)
{
foreach (var user in contactsList)
{
writer.Write(user.Id + ",");
writer.Write("\"" + System.Web.HttpUtility.HtmlDecode(user.LinkName) + "\",");
writer.Write(System.Web.HttpUtility.HtmlDecode(user.LinkMobile) + ",");
writer.Write("\"" + System.Web.HttpUtility.HtmlDecode(user.LinkEmails) + "\",");
writer.Write("\"" + System.Web.HttpUtility.HtmlDecode(user.LinkCompany) + "\",");
writer.Write(user.Name);
writer.WriteLine();
}
}
writer.Flush();
output.Position = ;
return File(output, "text/comma-separated-values", contactsfileName + ".csv"); } #region Oledb方式读取EXCEL 导入通讯录
/// <summary>
/// Oledb方式读取EXCEL
/// </summary>
/// <param name="fileNamePath">文件路径</param>
/// <returns>DataTable</returns>
private DataTable ReadExcelByOledb(string fileNamePath, EntMSM.Models.Users currentUser)
{
string connStr = "Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + fileNamePath + ";Extended Properties='Excel 12.0; HDR=Yes; IMEX=1'";
OleDbConnection oledbconn1 = new OleDbConnection(connStr);
oledbconn1.Open();
DataTable _table = oledbconn1.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" }); string strTableName = string.Empty;
if (_table.Rows.Count > )
{
strTableName = _table.Rows[]["TABLE_NAME"].ToString().Trim();
string sql = string.Format("SELECT * FROM [{0}]", strTableName);
_table = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter(sql, oledbconn1);
_table.Columns.Add(new DataColumn("Uses_Id", typeof(int)));
_table.Columns["Uses_Id"].DefaultValue = currentUser.Id;//设置该列默认值
da.Fill(_table);
}
oledbconn1.Close();
return _table;
}
/// <summary>
/// 利用NPOI读取Excel
/// </summary>
IWorkbook hssfworkbook;
public DataTable ImportExcelFile(string fileNamePath, string groupsId, EntMSM.Models.Users currentUser)
{
#region//初始化信息
string fileType = fileNamePath.Split('.')[].Trim();
try
{
using (FileStream file = new FileStream(fileNamePath, FileMode.Open, FileAccess.Read))
{
if (fileType == "xlsx")
{
hssfworkbook = new XSSFWorkbook(file);
}
else
{
hssfworkbook = new HSSFWorkbook(file);
}
}
}
catch (Exception e)
{
throw e;
}
#endregion ISheet sheet = hssfworkbook.GetSheetAt();
System.Collections.IEnumerator rows = sheet.GetRowEnumerator(); DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(Int32));
dt.Columns.Add("Uses_Id", typeof(Int32));
dt.Columns.Add("LinkName", typeof(string));
dt.Columns.Add("LinkMobile", typeof(string));
dt.Columns.Add("LinkEmails", typeof(string));
dt.Columns.Add("LinkCompany", typeof(string));
dt.Columns.Add("Groups_Id", typeof(Int32));
rows.MoveNext();
while (rows.MoveNext())
{
IRow row = null;
if (fileType == "xlsx")
{
row = (XSSFRow)rows.Current;
}
else
{
row = (HSSFRow)rows.Current;
} DataRow dr = dt.NewRow();
for (int i = ; i < ; i++)
{
ICell cell = row.GetCell(i);
if (i == )
{
if (cell == null)
{
dr[i] = null;
}
else
{
dr[i] = cell.ToString();
}
}
else if (i == )
{
dr[i] = currentUser.Id;
dr[i + ] = cell.ToString();
}
else if (i == )
{
dr[i+] =int.Parse(groupsId);
}
else
{
if (cell == null)
{
dr[i + ] = null;
}
else
{
dr[i + ] = cell.ToString();
}
}
}
dt.Rows.Add(dr);
}
return dt;
} /// <summary>
/// 读取csv
/// </summary>
/// <param name="filepath"></param>
/// <returns></returns>
private DataTable ReadCsv(string filepath,string groupsId ,EntMSM.Models.Users currentUser)
{
base.IsLogin();
StreamReader sr;
string strTol = string.Empty;
string strTemp = string.Empty;
DataTable dt = new DataTable();
EntMSM.Models.Users curr = Session["LoginUser"] as EntMSM.Models.Users;
int count = ;//导入成功的计数
try
{
sr = new StreamReader(filepath, Encoding.Default);
dt.Columns.Add("Id", typeof(Int32));
dt.Columns.Add("Uses_Id", typeof(Int32));
dt.Columns.Add("LinkName", typeof(string));
dt.Columns.Add("LinkMobile", typeof(string));
dt.Columns.Add("LinkEmails", typeof(string));
dt.Columns.Add("LinkCompany", typeof(string));
dt.Columns.Add("Groups_Id",typeof(Int32));
strTemp = sr.ReadLine();//跳过头部
strTemp = sr.ReadLine();//跳过模板号码 if (strTemp.Split(',').Length > )
{
//针对360手机助手导出的通讯录导入
while (!string.IsNullOrEmpty(strTemp))//如果还有数据,继续读数据
{
count++;
DataRow row = dt.NewRow();
string tel = strTemp.Split(',')[].Trim('"').Trim(' ');
row["Id"] = ;
row["Uses_Id"] = currentUser.Id;
row["LinkName"] = strTemp.Split(',')[].Trim('"').Trim(' ');
row["LinkMobile"] = tel;
row["LinkEmails"] = strTemp.Split(',')[].Trim('"').Trim(' ');
row["LinkCompany"] = strTemp.Split(',')[].Trim('"').Trim(' ');
row["Groups_Id"] =int.Parse(groupsId);
dt.Rows.Add(row);
strTemp = sr.ReadLine();//读取下一行 }
}
else
{
//普通格式的文档导入
while (!string.IsNullOrEmpty(strTemp))//如果还有数据,继续读数据
{
count++;
DataRow row = dt.NewRow();
string tel = strTemp.Split(',')[].Trim('"').Trim(' ');
row["Id"] = ;
row["Uses_Id"] = currentUser.Id;
row["LinkName"] = strTemp.Split(',')[].Trim('"').Trim(' ');
row["LinkMobile"] = tel;
row["LinkEmails"] = strTemp.Split(',')[].Trim('"').Trim(' ');
row["LinkCompany"] = strTemp.Split(',')[].Trim('"').Trim(' ');
row["Groups_Id"] =int.Parse(groupsId);
dt.Rows.Add(row);
strTemp = sr.ReadLine();//读取下一行 }
}
}
catch (Exception)
{
dt = null;
throw;
}
sr.Close();//关闭流
return dt; }
/// <summary>
/// 判断两个DataTable中,第一个dataTable中在第二个dataTable中不存在的记录集
/// </summary>
/// <param name="returnTable">返回的不重复的结果集</param>
/// <param name="table1">即将导入的数据集</param>
/// <param name="table2">数据库中的数据集</param>
/// <param name="fieldsStr">字段名</param>
/// <returns></returns>
public static DataTable ComPare2DataTable(DataTable table1, DataTable table2, string fieldsStr)
{
try
{
DataTable returnTable = new DataTable();
returnTable = table1.Clone(); //for循环将数据库中的table2的每行数据转换为一个字符串,保存的HashTable中
Hashtable hashtable = new Hashtable();
DataRow[] dataRows = table2.Select(""); string[] fieldArr = fieldsStr.Split(','); foreach (DataRow row in dataRows)
{
string rowStr = "";
for (int i = ; i < fieldArr.Length; i++)
{
Object obj = row[fieldArr[i]];
if (!String.IsNullOrEmpty(obj.ToString()))
{
rowStr += obj.ToString();
}
}
hashtable.Add(rowStr, "");
} //将要导入的DataTable,将每一行数据转换为字符串之后,在hashTable中找是否存在这个key,存在的加入返回的DataTable中,反之不加入。
DataRow[] dataRows1 = table1.Select();
foreach (DataRow row in dataRows1)
{
string rowStr1 = "";
for (int i = ; i < fieldArr.Length; i++)
{
Object obj = row[fieldArr[i]];
if (!String.IsNullOrEmpty(obj.ToString()))
{
rowStr1 += obj.ToString();
}
}
if (!hashtable.ContainsKey(rowStr1))
{
returnTable.Rows.Add(row.ItemArray);
}
}
return returnTable;
}
catch (Exception ex)
{
throw ex;
}
} /// <summary>
/// 文档上传 读取文档内容并保存到 数据库
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public string UploadFile()
{
string result = "导入失败!";
try
{
base.IsLogin();
int sucCount = ;
int allCount = ;
string reqs = Request.Form["fileName"];
string groupsId=Request.Form["groupsId"];
string strPath = Server.MapPath("/UpLoadFile/" + reqs);
EntMSM.Models.Users curr = Session["LoginUser"] as EntMSM.Models.Users;
DataTable dt = null;
DataTable dt1 = ConvertToDataTable(esd.ContactLists.Where(a => a.Uses_Id == curr.Id));
dt1.Columns["电话"].ColumnName = "LinkMobile";
if (reqs.Split('.')[].ToUpper() == "CSV")
{
dt = ReadCsv(strPath, groupsId, curr);//csv
}
else
{
dt = ImportExcelFile(strPath, groupsId, curr);
//ReadExcelByOledb(strPath, curr);//xls
// dt.Columns["电话"].ColumnName = "LinkMobile";
}
allCount = dt.Rows.Count;
//去掉重复行 ,重复数据过滤
DataTable dd = DeleteSameRow(dt, "LinkMobile");//去除上传文件中重复的数据
DataTable ddt = ComPare2DataTable(dd, dt1, "LinkMobile");//出去已经存在数据库中的重复数据 int currCount = ddt.Rows.Count;
for (int i = ; i < ddt.Rows.Count; )
{
//ddt.Rows[i][2] = System.Web.HttpUtility.HtmlEncode(ddt.Rows[i][2].ToString());
//ddt.Rows[i][3] = System.Web.HttpUtility.HtmlEncode(ddt.Rows[i][3].ToString());
//ddt.Rows[i][4] = System.Web.HttpUtility.HtmlEncode(ddt.Rows[i][4].ToString());
//ddt.Rows[i][5] = System.Web.HttpUtility.HtmlEncode(ddt.Rows[i][5].ToString());
if (ddt.Rows[i][].ToString().Trim() == "" || ddt.Rows[i][] == null || ddt.Rows[i][].ToString().Trim() == "" || ddt.Rows[i][] == null || ddt.Rows[i][].ToString().Trim() == "" || ddt.Rows[i][] == null)
{
ddt.Rows[i].Delete();
}
else
{
if (!IsChiOrEng(ddt.Rows[i][].ToString()))
{
ddt.Rows[i].Delete();
}
else if (!IsPhone(ddt.Rows[i][].ToString()))
{
ddt.Rows[i].Delete();
}
else if (!IsEmail(ddt.Rows[i][].ToString()))
{
ddt.Rows[i].Delete();
}
else if (StrLenth(ddt.Rows[i][].ToString()))
{
ddt.Rows[i].Delete();
}
else if (StrLenth(ddt.Rows[i][].ToString()))
{
ddt.Rows[i].Delete();
}
else if (StrLenth(ddt.Rows[i][].ToString()))
{
ddt.Rows[i].Delete();
}
else
{
i++;
}
}
} int twoCount = ddt.Rows.Count;
if (currCount > )
{
sucCount = addTable(ddt);
if (sucCount > )
{
result = "导入通讯录共计:" + allCount + "条\n\t导入成功:" + sucCount + "条\n\t过滤重复联系人:" + (allCount - currCount) + "条\n\t过滤错误数据:" + (currCount - twoCount) + "条";
}
else
{
result = "导入通讯录共计:" + allCount + "条\n\t导入成功:" + sucCount + "条\n\t过滤重复联系人:" + (allCount - currCount) + "条\n\t过滤错误数据:" + (currCount - twoCount) + "条";
}
}
else
{
result = "导入通讯录共计:" + allCount + "条\n\t导入成功:" + sucCount + "条\n\t过滤重复联系人:" + (allCount - currCount) + "条\n\t过滤错误数据:" + (currCount - twoCount) + "条";
}
if (System.IO.File.Exists(strPath)) //存在文件
{
System.IO.File.Delete(strPath);//删除文件
}
}
catch
{
result = "文档内容格式有误,导入失败!";
}
return result;
}
/// <summary>
/// 替换html中的特殊字符
/// </summary>
/// <param name="theString">需要进行替换的文本。</param>
/// <returns>替换完的文本。</returns>
public string HtmlEncode(string theString)
{
theString = theString.Replace(">", "&gt;");
theString = theString.Replace("<", "&lt;");
theString = theString.Replace("\"", "&quot;");
theString = theString.Replace("\'", "'");
theString = theString.Replace("\n", "<br/> ");
return theString;
}
#region 删除DataTable重复列,类似distinct
/// <summary>
/// 删除DataTable重复列,类似distinct
/// </summary>
/// <param name="dt">DataTable</param>
/// <param name="Field">字段名</param>
/// <returns></returns>
public static DataTable DeleteSameRow(DataTable dt, string Field)
{
ArrayList indexList = new ArrayList();
// 找出待删除的行索引
for (int i = ; i < dt.Rows.Count - ; i++)
{
if (!IsContain(indexList, i))
{
for (int j = i + ; j < dt.Rows.Count; j++)
{
if (dt.Rows[i][Field].ToString() == dt.Rows[j][Field].ToString())
{
indexList.Add(j);
}
}
}
}
indexList.Sort();
// 排序
for (int i = indexList.Count - ; i >= ; i--)// 根据待删除索引列表删除行
{
int index = Convert.ToInt32(indexList[i]);
dt.Rows.RemoveAt(index);
}
return dt;
} /// <summary>
/// 判断数组中是否存在
/// </summary>
/// <param name="indexList">数组</param>
/// <param name="index">索引</param>
/// <returns></returns>
public static bool IsContain(ArrayList indexList, int index)
{
for (int i = ; i < indexList.Count; i++)
{
int tempIndex = Convert.ToInt32(indexList[i]);
if (tempIndex == index)
{
return true;
}
}
return false;
}
#endregion
/// <summary>
/// 添加table
/// </summary>
/// <param name="dtt"></param>
/// <returns></returns>
public int addTable(DataTable dtt)
{
string a = ConfigurationManager.ConnectionStrings["EntSmsDbContext"].ToString();
SqlConnection con = new SqlConnection(a);
SqlCommand cmd = new SqlCommand("select * from ContactList", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
SqlCommandBuilder Builder = new SqlCommandBuilder(sda);
sda.Fill(dtt);
int states = sda.Update(dtt);
return states;
}
/// <summary>
/// 字符串长度
/// </summary>
/// <param name="len"></param>
/// <returns></returns>
public bool StrLenth(string len)
{ if (IsChinese(len))
{
if (len.ToString().Length > )
{
return true;
}
}
else
{
if (len.ToString().Length > )
{
return true;
}
}
return false;
}
/// <summary>
/// 判断是否为Email
/// </summary>
/// <param name="s">字符串</param>
/// <returns></returns>
public static bool IsEmail(string s)
{
return Regex.IsMatch(s, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
}
/// <summary>
/// 判断是否为手机号码格式
/// </summary>
/// <param name="s">字符串</param>
/// <returns></returns>
public static bool IsPhone(string s)
{
return Regex.IsMatch(s, @"^(((13[0-9]{1})|14[0-9]{1}|15[0-9]{1}|18[0-9]{1})+\d{8})$");
}
/// <summary>
/// 判断是否为中文字符
/// </summary>
/// <param name="s">字符串</param>
/// <returns></returns>
public static bool IsChinese(string s)
{
return Regex.IsMatch(s, @"[\u4e00-\u9fa5]");
}
/// <summary>
/// 验证用户名为中、英文
/// </summary>
/// <param name="val"></param>
/// <returns></returns>
public static bool IsChiOrEng(string val)
{
string strRegex = @"[\u4e00-\u9fa5_a-zA-Z]";
return Regex.IsMatch(val, strRegex);
}
/// <summary>
/// 判断是否为正整数
/// </summary>
/// <param name="s">字符串</param>
/// <returns></returns>
public static bool IsInt(string s)
{
return Regex.IsMatch(s, @"^\d+$");
}
#endregion /// <summary>
/// 非法字符转换
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public string ReplaceStr(string str)
{
//str=str.Replace(",","");
str = str.Replace("'", "");
str = str.Replace(";", "");
str = str.Replace(":", "");
str = str.Replace("/", "");
str = str.Replace("?", "");
str = str.Replace("<", "");
str = str.Replace(">", "");
str = str.Replace(".", "");
str = str.Replace("#", "");
str = str.Replace("%", "");
str = str.Replace("%", "");
str = str.Replace("^", "");
str = str.Replace("//", "");
str = str.Replace("@", "");
str = str.Replace("(", "");
str = str.Replace(")", "");
str = str.Replace("*", "");
str = str.Replace("~", "");
str = str.Replace("`", "");
str = str.Replace("$", "");
str = str.Replace("&", "");
str = str.Replace("\n", "");
return str;
} }
}

NPOI文件导入操作的更多相关文章

  1. C# Excel文件导入操作

    Excel文件导出的操作我们经经常使用到,可是讲一个Excel文档导入并显示到界面还是第一次用到. 以下简介下在C#下怎样进行Excel文件的导入操作. 首先加入两个引用 using System.I ...

  2. ajax模拟表单提交,后台使用npoi实现导入操作 方式一

    页面代码: <form id="form1" enctype="multipart/form-data"> <div style=" ...

  3. ajax模拟表单提交,后台使用npoi实现导入操作 方式二

    页面代码: <form id="form1" enctype="multipart/form-data"> <div style=" ...

  4. 3.数据库操作相关术语,Oracle认证,insert into,批量插入,update tablename set,delete和truncate的差别,sql文件导入

     1相关术语 语句 含义 操作 DML语句 (Data Manipulation Language) 数据库操作语言 insert update delete select DDL语言 (Date ...

  5. asp.net mvc4 easyui datagrid 增删改查分页 导出 先上传后导入 NPOI批量导入 导出EXCEL

    效果图 数据库代码 create database CardManage use CardManage create table CardManage ( ID ,) primary key, use ...

  6. 用NPOI实现导入导出csv、xls、xlsx数据功能

    用NPOI实现导入导出csv.xls.xlsx数据功能   直接上代码 首先定义一个接口   如果需要直接操作文件的话,就自己在封装一次 然后定义csv类的具体实现 这个需要引入命名空间LumenWo ...

  7. 使用NPOI进行Excel操作

    一.NPOI组件导入 右键项目菜单,“管理NuGet程序包” 直接搜索“NPOI”即会出现列表,下载第一个进行安装即可 安装完成后项目引用会出现以下几项 二.基础使用 添加引用 using NPOI. ...

  8. unity3d教程游戏包含的一切文件导入资源

    http://www.58player.com/blog-2327-954.html 导入资源 将文件增加至工程文件夹的资源 (Assets) 文件夹后,Unity 将自动检测文件.将任何资源 (As ...

  9. 用SQLSERVER里的bcp命令或者bulkinsert命令也可以把dat文件导入数据表

    用SQLSERVER里的bcp命令或者bulkinsert命令也可以把dat文件导入数据表 下面的内容的实验环境我是在SQLSERVER2005上面做的 之前在园子里看到两篇文章<C# 读取纯真 ...

随机推荐

  1. TP5.x——聊天列表查询

    前言 查询聊天列表,并返回最后一条聊天记录.这个有一个比较尴尬的点就是,一个是你主动发出的,一个是你接收的. 所以这个SQL会比较长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长 ...

  2. Hadoop一主一从部署(2)

    Hadoop部署一主一从(2) 1.关闭防火墙和Linux守护进程 执行命令: iptables -F setenforce 0 2.对Hadoop集群进行初始化,在namenode(主机)上执行命令 ...

  3. BZOJ 3930 容斥原理

    思路: 移至iwtwiioi    http://www.cnblogs.com/iwtwiioi/p/4986316.html //By SiriusRen #include <cstdio& ...

  4. .Net Core添加分布式Session

    一.Session HTTP是一个无状态协议,Web服务器将每一个请求都视为独立请求.并且不保存之前请求中用户的值. Session 状态是ASP.NET Core提供的一个功能,它可以在用户通应用访 ...

  5. 附加MySQL数据库的方法

    下面讲解附加MySQL数据库的方法. (1)将“光盘\Code\04\Project\数据库”文件夹中的扩展名为.sql的文件拷贝到本地机器中. (2)在如图1所示的MySQL工作台界面中,单击Dat ...

  6. C# 聚合数据借口发短信的使用

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  7. js对cookie增删改查的封装

    /** * 获取cookie * @param name * @returns {*} */ function getCookie(name) { var cookieArr = document.c ...

  8. openstack--memecache

    一.缓存系统 静态web页面: 1.工作流程: 在静态Web程序中,客户端使用Web浏览器(IE.FireFox等)经过网络(Network)连接到服务器上,使用HTTP协议发起一个请求(Reques ...

  9. python tips:迭代器与可迭代对象

    for循环 for i in s: print(i) 在上述for循环中,不断地将s中的值赋值给i,然后打印出来.这种只针对s中元素的循环称为对s的迭代,能够迭代的s称为可迭代的. python为了实 ...

  10. javeee 字节Buffered

    package Zy; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io. ...